<template>
	<view class="content">
		<view class="info">
			<view class="info1">
				<text>手机号码</text>
				<input type="number" v-model="mobilePhnNum" value="" placeholder="请输入手机号码" placeholder-class="inputStyle" />
			</view>

			<view class="info1">
				<text>车辆</text>
				<input type="number" v-model="italianItmVeh" value="" placeholder="请输入车辆" placeholder-class="inputStyle" />
			</view>

			<view class="info1" @click="open(1)">
				<text>送车时间</text>
				<input type="number" v-model="deliveryTm" value="" disabled placeholder="请输入送车时间" placeholder-class="inputStyle" />
			</view>

			<u-picker v-model="show1" mode="time" :params="params" @confirm="confirm1"></u-picker>

			<view class="info1" @click="open(0)">
				<text>还车时间</text>
				<input type="number" v-model="retTm" value="" disabled placeholder="请输入还车时间" placeholder-class="inputStyle" />
			</view>

			<u-picker v-model="show" mode="time" :params="params" @confirm="confirm"></u-picker>

			<view class="info1" @click="getMap(1)">
				<text>用车地点</text>
				<input type="text" v-model="location" value="" disabled placeholder="请输入用车地点" placeholder-class="inputStyle" />
			</view>

			<view class="info1" @click="getMap(0)">
				<text>还车地点</text>
				<input type="text" v-model="location1" value="" disabled placeholder="请输入还车地点" placeholder-class="inputStyle" />
			</view>
		</view>

		<view class="confirmUpload" @click="confirmUp">确认预约</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			params: {
				year: true,
				month: true,
				day: true,
				hour: true,
				minute: true,
				second: true,
			},
			italianItmVeh: '', // 车辆
			deliveryTm: '', // 送车时间
			retTm: '', // 还车时间
			show1: false,
			show: false,
			location: '',
			location1: '',
			mobilePhnNum: '', // 手机号码
		};
	},
	onLoad(e) {
		this.oid = e.oid;
	},
	methods: {
		async getMap(i) {
			if (i) {
				//const res = await uni.chooseLocation();
				const [,{ name, address, longitude, latitude }] = await uni.chooseLocation();
				console.log('位置名称：' + name);
				console.log('详细地址：' + address);
				console.log('经度：' + longitude);
				console.log('纬度：' + latitude);
				this.location = res[1].address;
			} else {
				const res = await uni.chooseLocation();
				this.location1 = res[1].address;
			}
		},
		open(i) {
			if (i) {
				this.show1 = true;
			} else {
				this.show = true;
			}
		},

		confirm1(e) {
			this.show1 = false;

			this.deliveryTm = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
			console.log('this.deliveryTm :>> ', this.deliveryTm);
		},
		confirm(e) {
			this.show = false;

			this.retTm = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
			console.log('this.retTm :>> ', this.retTm);
		},
		async confirmUp() {
			if (!this.location) return uni.$showMsg('不能为空');
			if (!this.location1) return uni.$showMsg('不能为空');
			if (!this.mobilePhnNum) return uni.$showMsg('不能为空');
			if (!this.retTm) return uni.$showMsg('不能为空');
			if (!this.deliveryTm) return uni.$showMsg('不能为空');
			if (!this.italianItmVeh) return uni.$showMsg('不能为空');

			const res = await this.$u.post('api/user/search_intention  ', {
				uid: uni.getStorageSync('uid'),
				phone: this.mobilePhnNum, // 联系方式
				intention: this.italianItmVeh, // 意向车辆
				car_take: this.location, // 送车地点
				time_take: this.deliveryTm, // 送车时间
				car_also: this.location1, // 还车地点
				time_also: this.retTm, // 还车时间
			});
			uni.switchTab({
				url: '../../index/index',
			});

			uni.$showMsg(res.msg);
			console.warn('res :>> ', res);
		},
	},
};
</script>

<style lang="scss" scoped>
.content {
	width: 100vw;
	height: 100vh;
	overflow: scroll;
	padding: 30rpx;
	.info {
		width: 690rpx;
		//height: 689rpx;
		background: #2a2929;
		box-shadow: 0rpx 0rpx 18rpx 0rpx rgba(51, 51, 51, 0.1);
		border-radius: 20rpx;
		padding: 25rpx 31rpx 31rpx 31rpx;
		margin: 0 auto;

		.info1 {
			display: flex;
			flex-direction: column;
			justify-content: center;
			height: 131rpx;
			// margin-left: 29rpx;
			border-bottom: 2rpx solid #f1eded;

			text {
				font-size: 36rpx;
				font-family: 'Microsoft YaHei', PingFang SC;
				font-weight: 400;
				color: #ffffff;
			}

			text:before {
				content: '*';
				color: #ff0000;
			}

			.inputStyle {
				font-size: 30rpx;
				font-family: 'Microsoft YaHei', PingFang SC;
				font-weight: 400;
				color: #ffffff;
			}
			input {
				color: #ffffff;
				padding-left: 20rpx;
				//margin-top: 10rpx;
			}
		}
	}

	.idCrd {
		width: 690rpx;
		//height: 300rpx;
		background: #2a2929;
		border-radius: 20rpx;
		padding: 30rpx;
		margin-top: 20rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		.ddd {
			display: flex;
			//justify-content: flex-start;
			flex-wrap: wrap;
			//padding: 0  30rpx;
			image {
				width: 100%;
				height: 100%;
			}
			.image {
				width: 250rpx;
				height: 180rpx;
				border: 1rpx dashed #606266;
				border-radius: 10rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-left: 40rpx;
				margin-bottom: 20rpx;
			}
		}

		text {
			height: 34rpx;
			line-height: 34rpx;
			font-size: 36rpx;
			font-family: 'Microsoft YaHei', PingFang SC;
			font-weight: 400;
			color: #ffffff;
		}

		text:before {
			content: '*';
			color: #ff0000;
		}
		/deep/ .u-list-item {
			background: none !important;
			border: 1rpx dashed #606266;
			margin-right: 30rpx !important;
		}
		/deep/ .u-upload {
			// display: flex !important;
			// justify-content: space-between !important;
		}
	}
	.confirmUpload {
		margin: 0 auto;
		margin-top: 99rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 690rpx;
		height: 100rpx;
		background: #d60000;
		border-radius: 50rpx;

		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #ffffff;
	}
}
</style>
